import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * <p>
 * JobMain
 * </p>
 *
 * @author: lianjun
 * @since: 2022-02-16
 */
public class JobMain {
    /** 固定的线程池（当前线程池大小为5） */
    private static final ExecutorService executor = Executors.newFixedThreadPool(10);

    public static void main(String[] args) throws InterruptedException {
        // 初始化计时器
        CountDownLatch cdl = new CountDownLatch(10);
        for(int i=0;i<10;i++){
            // 开启线程
            int finalI = i;
            executor.submit(() -> {
                var t = new TaskJob();
                System.out.println("job start " + finalI);
                try {
                    t.gensql(finalI *100000, finalI);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                System.out.println("job end " + finalI);
                // 闭锁-1
                cdl.countDown();
            });
        }

        cdl.await();

    }
}
